home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / file / managers / mc-3.2 / mc-3 / mc-3.2.1 / src / widget.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-17  |  6.4 KB  |  195 lines

  1. #ifndef __WIDGET_H
  2. #define __WIDGET_H
  3.  
  4. #define C_BOOL        1
  5. #define C_CHANGE    2
  6.  
  7. /* Please note that the first element in all the widgets is a     */
  8. /* widget variable of type Widget.  We abuse this fact everywhere */
  9. /* Widget_Items */
  10.  
  11. typedef struct WButton {
  12.     Widget widget;
  13.     int action;            /* what to do when pressed */
  14.     unsigned int selected;    /* button state */
  15.     char *text;            /* text of button */
  16.     int  hotkey;                /* hot KEY */
  17.     int  hotpos;                /* offset hot KEY char in text */
  18.     int  (*callback)(int, void*); /* Callback function */
  19.     void *callback_data;
  20. } WButton;
  21.  
  22. typedef struct WRadio {
  23.     Widget widget;
  24.     unsigned int state;        /* radio button state */
  25.     int pos, sel;
  26.     int count;            /* number of members */
  27.     char **texts;        /* texts of labels */
  28.     int upper_letter_is_hotkey; /* If true, then the capital letter is a hk */
  29. } WRadio;
  30.  
  31. typedef struct WCheck {
  32.     Widget widget;
  33.     unsigned int state;        /* check button state */
  34.     char *text;            /* text of check button */
  35.     int hotkey;                 /* hot KEY */                    
  36.     int hotpos;            /* offset hot KEY char in text */
  37. } WCheck;
  38.  
  39. typedef struct WGauge {
  40.     Widget widget;
  41.     int shown;
  42.     int max;
  43.     int current;
  44.     int pixels;            /* Only used for Tk:
  45.                  * We keep the pixel size in the C code
  46.                  * so that we can compute quickly compute
  47.                  * the size of the rectangle in the Tk
  48.                  * canvas.  Using Tcl would be too slow.
  49.                  */
  50. } WGauge;
  51.  
  52. typedef struct hist_entry {
  53.     struct hist_entry *prev;
  54.     struct hist_entry *next;
  55.     char   *text;
  56. } Hist;
  57.  
  58. typedef struct {
  59.     Widget widget;
  60.     int  point;            /* cursor position in the input line */
  61.     int  mark;            /* The mark position */
  62.     int  first_shown;        /* Index of the first shown character */
  63.     int  current_max_len;    /* Maximum length of input line */
  64.     int  field_len;        /* Length of the editing field */
  65.     int  color;            /* color used */
  66.     int  first;            /* Is first keystroke? */
  67.     int  disable_update;    /* Do we want to skip updates? */
  68.     int  is_password;        /* Is this a password input line? */
  69.     char *buffer;        /* pointer to editing buffer */
  70.     Hist *history;        /* The history */
  71.     int  need_push;        /* need to push the current Input on hist? */
  72.     char **completions;        /* Possible completions array */
  73.     int  completion_flags;    /* INPUT_COMPLETE* bitwise flags(complete.h) */
  74.     int  inserted_one;        /* TK: just one char inserted, nothing fancy */
  75. } WInput;
  76.  
  77. typedef struct {
  78.     Widget widget;
  79.     int    auto_adjust_cols;    /* compute widget.cols from strlen(text)? */
  80.     char   *text;
  81.     int       transparent;        /* Paint in the default color fg/bg */
  82. } WLabel;
  83.  
  84. typedef struct WLEntry {
  85.     char *text;            /* Text to display */
  86.     int  hotkey;
  87.     void *data;            /* Client information */
  88.     struct WLEntry *next;
  89.     struct WLEntry *prev;
  90. } WLEntry;
  91.  
  92. enum {
  93.     listbox_begin, listbox_end
  94. } /* listbox_insert */;
  95.  
  96. /* Listbox actions when selecting an option: */
  97. enum {
  98.     listbox_nothing,
  99.     listbox_finish,        /* finish dialog */
  100.     listbox_cback        /* call the callback routine */
  101. } /* listbox_action */;
  102.  
  103. typedef int (*lcback) (void *);
  104.  
  105. typedef struct {
  106.     Widget widget;
  107.     WLEntry *list;        /* Pointer to the circular double linked list. */
  108.     WLEntry *top;        /* The first element displayed */
  109.     WLEntry *current;        /* The current element displayed */
  110.     int pos;            /* Cur. pos, must be kept in sync with current */
  111.     int count;            /* Number of items in the listbox */
  112.     int width;
  113.     int height;            /* Size of the widget */
  114.     int action;            /* Action type */
  115.     int allow_duplicates;    /* Do we allow duplicates on the list? */
  116.     int scrollbar;        /* Draw a scrollbar? */
  117.     lcback cback;        /* The callback function */
  118.     int cursor_x, cursor_y;    /* Cache the values */
  119. } WListbox;
  120.  
  121. typedef struct {
  122.     Widget widget;
  123.     int    visible;        /* Is it visible? */
  124.     struct {
  125.     char   *text;
  126.     void   (*function)(void *data);
  127.     void   *data;
  128.     } labels [10];
  129. } WButtonBar;
  130.  
  131. /* Constructors */
  132. WButton *button_new (int y, int x, int action, char *text, int hkey, int hpos,
  133.              int (*callback)(int, void *), void *extra);
  134. WRadio  *radio_new  (int y, int x, int count, char **text, int use_hotkey);
  135. WCheck  *check_new  (int y, int x, int state,  char *text, int hkey, int hpos);
  136. WInput  *input_new  (int y, int x, int color, int len, char *text);
  137. WLabel  *label_new  (int y, int x, char *text);
  138. WGauge  *gauge_new  (int y, int x, int shown, int max, int current);
  139. WListbox *listbox_new (int x, int y, int width, int height, int action,
  140.                lcback);
  141.  
  142. /* Input lines */
  143. void winput_set_origin (WInput *i, int x, int field_len);
  144. int handle_char (WInput *in, int c_code);
  145. int is_in_input_map (WInput *in, int c_code);
  146. void update_input (WInput *in);
  147. void new_input (WInput *in);
  148. int push_history (WInput *in, char *text);
  149. void stuff (WInput *in, char *text, int insert_extra_space);
  150. void input_disable_update (WInput *in);
  151. void input_set_prompt (WInput *in, int field_len, char *prompt);
  152. void input_enable_update (WInput *in);
  153. void input_set_point (WInput *in, int pos);
  154. void input_show_cursor (WInput *in);
  155. void assign_text (WInput *in, char *text);
  156.  
  157. /* Labels */
  158. void label_set_text (WLabel *label, char *text);
  159.  
  160. /* Gauges */
  161. void gauge_set_value (WGauge *g, int max, int current);
  162. void gauge_show (WGauge *g, int shown);
  163.  
  164. /* Buttons */
  165. void button_set_text (WButton *b, char *text);
  166.  
  167. /* Listbox manager */
  168. char *listbox_add_item (WListbox *l, int pos, int hotkey, char *text,
  169.                void *data);
  170. WLEntry *listbox_get_data (WListbox *l, int pos);
  171.  
  172. /* search text int listbox entries */
  173. WLEntry *listbox_search_text (WListbox *l, char *text);
  174. void listbox_select_entry (WListbox *l, WLEntry *dest);
  175. void listbox_select_by_number (WListbox *l, int n);
  176. void listbox_select_last (WListbox *l, int set_top);
  177. void listbox_remove_current (WListbox *l);
  178. void listbox_get_current (WListbox *l, char **string, char **extra);
  179.  
  180. /* Hintbar routines */
  181.  
  182. /* Buttonbar routines */
  183. WButtonBar *buttonbar_new (int visible);
  184. typedef void (*buttonbarfn )(void *);
  185. typedef void (*voidfn)(void);
  186. void define_label (Dlg_head *, Widget *paneletc, int index, char *text, voidfn);
  187. void define_label_data (Dlg_head *h, Widget *paneletc, int idx, char *text,
  188.             buttonbarfn cback, void *data);
  189. void set_label_text (WButtonBar *, int, char *);
  190. void redraw_labels (Dlg_head *h, Widget *paneletc);
  191. WButtonBar *find_buttonbar (Dlg_head *h, Widget *paneletc);
  192. void buttonbar_hint (WButtonBar *bb, char *s);
  193.  
  194. #endif    /* __WIDGET_H */
  195.